<template>
	<view class="mian">
		<!-- #ifdef MP-WEIXIN -->
			<navbar :bgColor="bgColor" :btnColors='btnColor' title="积分兑换记录" :isGoBack="true" :isNotice="true" :visible="true"></navbar>
		<!-- #endif -->	
		<view class="points_top">						
		  <block v-if="list.length > 0"  v-for="(goods,index1) in list"   :key="index1" >
			  <view style="background: #fff;margin-bottom: 20rpx;pading-right: 20rpx;padding-left: 20rpx;" >
				<view class="order_main" @click="goDetails(goods.id)">
					<view class="flex justify-between ml-25 mr-25 text-dff pt-20 border-b pb-15">	                         
					  <view class="pt-10 text-df" style="color: #000;;">订单号：{{goods.order_no}}</view>
					  <view style="color: #518FA0 ; margin-top: 10rpx;" v-if="goods.status==1">已发货</view>									  								
					  <view style='color: gray;margin-top: 10rpx;'    v-if="goods.status==0">待发货</view>
					  <view style='color: #000;margin-top: 10rpx;'   v-if="goods.status==2">已完成</view>
					</view>  
					
					<view class="order_list flex border-b">
						<block>
							<view class="flex mt-20 mb-20 " style="width: 100%;align-items: center;">
								  <view slot='icon' class="flex align-center" >
									<image class="grid-img" :src="goods.goods_image" bindtap="handleChangeGoods" 	mode="scaleToFill"></image>
								  </view>								  
								  <view class="flex flex-direction ml-10" style="width: 100%;">
									<view  style="width: 100%;">
									  <view class='flex align-center cell text-lg mb-10' style="color: #4D4D4D;">{{goods.goods_title}}</view>
									  <view class='flextext-sm text-gray mb-10 mr-25 mt-10'>
										  积分 {{goods.goods_points}}													   
									  </view>
									  <view class='flextext-time text-gray mb-10 mr-25 mt-10'>
										  兑换时间 {{goods.create_at}}													   
									  </view>
									</view>												
									
								 </view>
							</view>
						</block>                   
				   </view>	
				</view>		
				<view class="flex pb-15 mt-10 mr-20" style="justify-content:flex-end;">								
					<view class="mt-25 ml-20" v-if="goods.status==1">
						<u-button text="确认收货" shape="circle" type="primary" :plain="true" size="small" color="#518FA0" class="ml-20" customStyle="width:150rpx"@click="dofinish(goods.id)" ></u-button>
					</view>									
					<view class="mt-25 ml-20" v-if="goods.status==1">
						<u-button text="查看物流" shape="circle" type="primary" :plain="true" size="small" color="#518FA0" class="ml-20" customStyle="width:150rpx"@click="paykd(goods.id)" ></u-button>
					</view>														
				</view>
			  </view>
			</block>
		</view>	
	</view>	
</template> 
<script>
	export default {
		data() {
			return {
				...getApp().globalData.config,		
				page:1,
				list:[],
				winHeight:'',
			};
		},
		onLoad(events) {
			
			let height = uni.getSystemInfoSync().windowHeight;
			this.winHeight = (height - 54);
		    this._requestPageList()
		},
		onShow(){
			this.page=1
			this.list=[]
			this.query_goods_list()
		},
		methods: {
			...getApp().globalData.function,	
            query_goods_list(){
            	let obj={
            		token:uni.getStorageSync('userInfo').token,
            		page:this.page
            	}
            	this.$http.changeGoodslog(obj).then(res=>{
            		if(res.resCode=='9999'){						
            			this.list = [...this.list, ...res.data.list]
            		}
            	})
            },
            onReachBottom() {
            	console.log("到底了")
            	this.page++; // 每触底一次 page +1
            	this.query_goods_list()
            },
			//详情
			goDetails(id){
				this.$routers.router('/pages/pagesuser/points/order_detail?id='+id,'navigateTo') 
			},
			//快递信息
			paykd(id){
				this.$routers.router('/pages/pagesuser/points/order_kd?id='+id,'navigateTo') 
			},
			//确认收货
			dofinish(order_id){
			  let that = this;			   
			  this.$showModal({content: '您确定已经收到货物了吗？',title:'提示'}).then(res=>{
				if(res.confirm){
				  let obj_data={
					token:uni.getStorageSync('userInfo').token,
					orderId:order_id
				  }
				  this.$http.confirm_Points(obj_data).then(res=>{
					that.$showToast(res.resMessage) 
					setTimeout(()=>{
						this.page=1
						this.list=[]
						this.query_goods_list()
					},3000)          
				  })
				}
			  })
			},
		},
	};
</script>
 
<style scoped lang="scss">
	
		@import url("./exchange.css");
</style>